<?php
/*项目入口根模块*/
class AllAction extends Action{
    //构造函数
    public function _initialize(){
        header("Content-Type:text/html; charset=utf-8");
    }
	//影视栏目页变量定义
	public function Lable_Vod_List($param,$array_list){
		$array_list['sid'] = 1;
		$array_list['list_area'] = $param['area'];
		$array_list['list_langaue'] = $param['langaue'];
		$array_list['list_year'] = $param['year'];
		$array_list['list_actor'] = $param['actor'];
		$array_list['list_director'] = $param['director'];
		$array_list['list_title'] = $param['title'];
		$array_list['list_wd'] = $param['wd'];
		$array_list['list_page'] = $param['page'];
		$array_list['list_letter'] = $param['letter'];
		$array_list['list_order'] = 'vod_'.$param['order'];
		if ($param['page'] > 1) {
			$array_list['title'] = $array_list['list_name'].'-第'.$param['page'].'页';
		}else{
			$array_list['title'] = $array_list['list_name'];
		}
		$array_list['title'] = $array_list['list_area'].$array_list['list_langaue'].$array_list['list_actor'].$array_list['list_director'].$array_list['title'].'-'.C('site_name');
		if (empty($array_list['list_skin'])) {
			$array_list['list_skin'] = 'pp_vodlist';
		}
		return $array_list;
    }
	/*****************影视内容,播放页变量定义******************************
	* @$array/具体的内容信息
	* @$array_play 为解析播放页
	* @返回赋值后的arrays 多维数组*/
	public function Lable_Vod_Read($array,$array_play = false){
		$array_list = list_search(F('_ppvod/list'),'list_id='.$array['vod_cid']);
		//播放列表
		$array['vod_playlist'] = $this->ff_playlist_all($array);
		$array['vod_count'] = $array['vod_playlist'][0]['playcount'];
		//2.0新加参数
		$array['vod_readurl'] = ff_data_url('vod',$array['vod_id'],$array['vod_cid'],$array['vod_name'],1,$array['vod_jumpurl']);
		$array['vod_playurl'] = ff_play_url($array['vod_id'],0,1,$array['vod_cid'],$array['vod_name']);
		$array['vod_picurl'] = ff_img_url($array['vod_pic'],$array['vod_content']);
		$array['vod_picurl_small'] = ff_img_url_small($array['vod_pic'],$array['vod_content']);
		$array['vod_hits_insert'] = ff_get_hits('vod','insert',$array);
		$array['vod_hits_month'] = ff_get_hits('vod','vod_hits_month',$array);
		$array['vod_hits_week'] = ff_get_hits('vod','vod_hits_week',$array);
		$array['vod_hits_day'] = ff_get_hits('vod','vod_hits_day',$array);
		$array['vod_rssurl'] = UU('Home-map/rss',array('id'=>$array['vod_id']),false,true);
		$array['title'] = $array['vod_name'].'-'.C('site_name');
		$array['sid'] = 1;
		//播放页独立参数
		if($array_play){
			$player = C('play_player');
			$player_here = explode('$$$',$array['vod_play']);
			$array['vod_sid'] = $array_play['sid'];
			$array['vod_pid'] = $array_play['pid'];
			$array['vod_playname'] = $player_here[$array_play['sid']];
			$array['vod_playername'] = $player[$array['vod_playname']][1];
			$array['vod_playekey'] = $player[$array['vod_playname']][0];
			$array['vod_jiname'] = $array['vod_playlist'][$array['vod_playekey'].'-'.$array_play['sid']]['son'][$array_play['pid']-1]['playname'];
			$array['vod_playpath']= $array['vod_playlist'][$array['vod_playekey'].'-'.$array_play['sid']]['son'][$array_play['pid']-1]['playpath'];
			$array['vod_nextpath']= $array['vod_playlist'][$array['vod_playekey'].'-'.$array_play['sid']]['son'][$array_play['pid']]['playpath'];
			//
			$array['title'] = '正在播放 '.$array['vod_name'].'-'.$array['vod_jiname'].'-'.C('site_name');
			$array['vod_hits_month'] = ff_get_hits('vod','vod_hits_month',$array,C('url_html_play'));
			$array['vod_hits_week'] = ff_get_hits('vod','vod_hits_week',$array,C('url_html_play'));
			$array['vod_hits_day'] = ff_get_hits('vod','vod_hits_day',$array,C('url_html_play'));	
			$array['vod_skin'] = !empty($array['vod_skin']) ? 'Home:play_'.$array['vod_skin'] : 'Home:pp_play';			
			//生成播放地址列表
			$pp_play = '<script language="javascript">'."\n";		
			$pp_play .= 'var vod_name="'.$array['vod_name'].'";';
			$pp_play .= 'var list_name="<a href='.$array_list[0]['list_url'].'>'.$array_list[0]['list_name'].'</a>";';
			$pp_play .= 'var server_name="'.$array['vod_server'].'";';
			$pp_play .= 'var player_name="'.$array['vod_play'].'";';
			$pp_play .= 'var url_list="'.$this->ff_playlist_string($array['vod_playlist']).'";';
			$pp_play .= '</script>'."\n";
			$pp_play .= '<script language="javaScript" src="'.C('site_path').'Runtime/Player/play.js"></script>'."\n";
			$pp_play .= '<script language="javaScript" src="'.C('site_path').'Public/player/play.js"></script>'."\n";
			$array['vod_player'] = $pp_play;		
		}else{
			$array['vod_skin'] = !empty($array['vod_skin']) ? 'Home:'.$array['vod_skin'] : 'Home:pp_vod';
		}
		$arrays['show'] = $array_list[0];
		$arrays['read'] = $array;
		return $arrays;
	}
	//组合播放地址组列表为二维数组
	public function ff_playlist_all($array){
		$playlist = array();
		$array_player = explode('$$$',$array['vod_play']);
		$array_server = explode('$$$',$array['vod_server']);
		$array_urllist = explode('$$$',$array['vod_url']);
		$player = C('play_player');
		$server = C('play_server');
		foreach($array_player as $sid=>$val){
			$playlist[$player[$val][0].'-'.$sid] = array('servername' => $array_server[$sid],'serverurl' => $server[$array_server[$sid]],'playername'=>$player[$val][1],'playname'=>$val,'son' => $this->ff_playlist_one($array_urllist[$sid],$array['vod_id'],$sid,$array['vod_cid'],$array['vod_name']));
		}
		ksort($playlist);
	    return $playlist;
	}
	//分解单组播放地址链接
	public function ff_playlist_one($urlone,$id,$sid,$cid,$name){
		$urllist = array();
	    $array_url = explode(chr(13),str_replace(array("\r\n", "\n", "\r"),chr(13),$urlone));
		foreach($array_url as $key=>$val){
		    if (strpos($val,'$') > 0) {
		        $ji = explode('$',$val);
			    $urllist[$key]['playname'] = trim($ji[0]);
			    $urllist[$key]['playpath'] = trim($ji[1]);
			}else{
			    $urllist[$key]['playname'] = '第'.($key+1).'集';
			    $urllist[$key]['playpath'] = trim($val);
			}
			$urllist[$key]['playurl'] = ff_play_url($id,$sid,$key+1,$cid,$name);
			$urllist[$key]['playcount'] = count($array_url);
		}
	    return $urllist;
	}
	//生成播放列表字符串
	public function ff_playlist_string($array_vod_playlist){
		foreach($array_vod_playlist as $key=>$val){
			$array_one = array();
			foreach($val['son'] as $keysub=>$valsub){
				$array_one[$keysub] = $valsub['playname'].'++'.$valsub['playpath'];
			}
			$array_all[$key] = implode('+++',$array_one);
		}
		return urlencode(implode('$$$',$array_all));
	}
	//资讯栏目页变量定义
	public function Lable_News_List($param,$array_list){
		$array_list['sid'] = 2;
		$array_list['list_wd'] = $param['wd'];	
		$array_list['list_page'] = $param['page'];
		$array_list['list_letter'] = $param['letter'];
		$array_list['list_order'] = 'news_'.$param['order'];
		if ($param['page'] > 1) {
			$array_list['title'] = $array_list['list_name'].'-第'.$param['page'].'页';
		}else{
			$array_list['title'] = $array_list['list_name'];
		}
		$array_list['title'] = $array_list['list_area'].$array_list['list_langaue'].$array_list['list_actor'].$array_list['list_director'].$array_list['title'].'-'.C('site_name');
		if (empty($array_list['list_skin'])) {
			$array_list['list_skin'] = 'pp_newslist';
		}
		return $array_list;
    }	
	//资讯内容页变量定义
	public function Lable_News_Read($array,$array_play = false){
		$array_list = list_search(F('_ppvod/list'),'list_id='.$array['news_cid']);
		$array['news_readurl'] = ff_data_url('news',$array['news_id'],$array['news_cid'],$array['news_name'],1,$array['news_jumpurl']);
		$array['news_picurl'] = ff_img_url($array['news_pic'],$array['news_content']);
		$array['news_picurl_small'] = ff_img_url_small($array['news_pic'],$array['news_content']);
		$array['news_hits_insert'] = ff_get_hits('news','insert',$array);
		$array['news_hits_month'] = ff_get_hits('news','news_hits_month',$array);
		$array['news_hits_week'] = ff_get_hits('news','news_hits_week',$array);
		$array['news_hits_day'] = ff_get_hits('news','news_hits_day',$array);
		$array['news_skin'] = !empty($array['news_skin']) ? 'Home:'.$array['news_skin'] : 'Home:pp_news';
		$array['title'] = $array['news_name'].'-'.C('site_name');
		$array['sid'] = 2;
		$arrays['show'] = $array_list[0];
		$arrays['read'] = $array;
		return $arrays;
	}	
	//搜索页变量定义
	public function Lable_Search($param,$sidname = 'vod'){
		if($sidname == 'vod'){
			$array_search['search_actor'] = $param['actor'];
			$array_search['search_director'] = $param['director'];			
			$array_search['search_area'] = $param['area'];
			$array_search['search_langaue'] = $param['langaue'];
			$array_search['search_year'] = $param['year'];
			$array_search['sid'] = 1;
		}else{
			$array_search['sid'] = 2;
		}
		$array_search['search_wd'] = $param['wd'];
		$array_search['search_name'] = $param['name'];
		$array_search['search_title'] = $param['title'];
		$array_search['search_page'] = $param['page'];
		$array_search['search_letter'] = $param['letter'];
		$array_search['search_order'] = $sidname.'_'.$param['order'];
		$array_search['search_skin'] = 'pp_'.$sidname.'search';
		if ($param['page'] > 1) {
			$array_search['title'] = $array_search['search_wd'].'-第'.$param['page'].'页';
		}else{
			$array_search['title'] = $array_search['search_wd'];
		}
		$array_search['title'] = $array_search['search_area'].$array_search['search_langaue'].$array_search['search_actor'].$array_search['search_director'].$array_search['title'].'-'.C('site_name');
		return $array_search;
    }	
	//Tag页变量定义
	public function Lable_Tags($param){
		$array_tag['tag_name'] = $param['wd'];
		$array_tag['tag_url'] = ff_tag_url($param['wd']);
		$array_tag['tag_page'] = $param['page'];
		if ($param['page'] > 1) {
			$array_tag['title'] = $array_tag['tag_name'].'-第'.$param['page'].'页-'.C('site_name');
		}else{
			$array_tag['title'] = $array_tag['tag_name'].'-'.C('site_name');
		}
		return $array_tag;
    }	
	//首页标签定义
	public function Lable_Index(){
		$array = array();
		$array['title'] = C('site_name');		
		return $array;
	}
	//地图页标签定义
	public function Lable_Maps($mapname,$limit,$page){
		$rs = M("Vod");
		$list = $rs->order('vod_addtime desc')->limit($limit)->page($page)->select();
		if($list){
			foreach($list as $key=>$val){
				$list[$key]['vod_readurl'] = ff_data_url('vod',$list[$key]['vod_id'],$list[$key]['vod_cid'],$list[$key]['vod_name'],1,$list[$key]['vod_jumpurl']);
				$list[$key]['vod_playurl'] = ff_play_url($list[$key]['vod_id'],0,1,$list[$key]['vod_cid'],$list[$key]['vod_name']);
			}
			return $list;			
		}
		return false;
    }
	//全局标签定义
	public function Lable_Style(){
		$array['model'] = strtolower(MODULE_NAME);
		$array['action'] = strtolower(ACTION_NAME);	
		C('TOKEN_NAME','form_'.$array['model']);
		$array = array();
		$array['pplink'] = F('_ppvod/link');
		$array['ppmenu'] = F('_ppvod/listtree');
		$array['root'] = __ROOT__.'/';
		$array['tpl'] = $array['root'].str_replace('./','',TEMPLATE_PATH).'/';
		$array['css'] = '<link rel="stylesheet" type="text/css" href="'.$array['tpl'].'style.css">'."\n";
		$array['sitename'] = C('site_name');
		$array['siteurl'] = C('site_url');
		$array['sitehot'] = ff_hot_key(C('site_hot'));
		$array['keywords'] = C('site_keywords');
		$array['description'] = C('site_description');
		$array['email'] = C('site_email');
		$array['copyright'] = C('site_copyright');
		$array['tongji'] = C('site_tongji');
		$array['icp'] = C('site_icp');
		$array['hotkey']   = ff_hot_key(C('site_hot'));
		//$array['username'] = $_COOKIE['bd_username'];
		//$array['userid'] = intval($_COOKIE['bd_userid']);
		$array['url_tag'] = UU('Home-tag/index','',false,true);		
		$array['url_guestbook'] = UU('Home-gb/show','',false,true);
		$array['url_map_rss'] = ff_map_url('rss');
		$array['url_map_baidu'] = ff_map_url('baidu');
		$array['url_map_google'] = ff_map_url('google');
		$array['url_map_soso'] = ff_map_url('soso');
		return $array;		
	}					
}
?>